package cn.tedu.csmall.product.controller;

import cn.tedu.csmall.product.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmall.product.pojo.dto.AlbumUpdateDTO;
import cn.tedu.csmall.product.pojo.dto.SpuAddNewDTO;
import cn.tedu.csmall.product.pojo.vo.AlbumListItemVO;
import cn.tedu.csmall.product.pojo.vo.AlbumStandardVO;
import cn.tedu.csmall.product.service.IAlbumService;
import cn.tedu.csmall.product.service.ISpuService;
import cn.tedu.csmall.product.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 处理SPU相关请求的控制器
 *
 * @author 何惠民
 * @version 0.0.1
 */
@Validated
@Api(tags = "08SPU模块")
@Slf4j
@RestController
@RequestMapping( "/spu")
public class SpuController {

    @Autowired
    private ISpuService spuService;

    public SpuController() {
        log.debug("创建控制器对象:SpuController");
    }
    @ApiOperation("添加SPU")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public JsonResult<Void> addNewAlbum(@Valid SpuAddNewDTO spuAddNewDTO){
        log.debug("开始处理[添加SPU]的请求,参数{}",spuAddNewDTO);
        spuService.addNew(spuAddNewDTO);
        log.debug("添加SPU数据成功");
        return JsonResult.ok();
    }

}
